﻿#include "frmmain.h"
#include "qthelper.h"
#include "common/configmanager/configmanager.h"
//#include "common/log/log.h"
#include "api/application.h"
#include <spdlog/spdlog.h>
#include <iostream>
#include <QDebug>
#include <csignal>
#include <QtMqtt/qmqttclient.h>
#include "mqttclient.h"
#pragma comment(lib, "ws2_32.lib")
void signalHandler(int signal)
{
    if (signal == SIGINT)
    {
        qInfo() << "Stopping directory monitoring signal" << signal;
    }
    qInfo() << "Stoppin"
               ""
               "g directory monitoring signal" << signal;

    QCoreApplication::quit();
}


int main(int argc, char *argv[])
{
    SPDLOG_INFO("=========={}", argc);

#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
    QApplication::setAttribute(Qt::AA_Use96Dpi);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
    QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
#endif

    QApplication a(argc, argv);
    a.setWindowIcon(QIcon(":/main.ico"));
    // 设置信号处理函数
    std::signal(SIGINT, signalHandler);
    //设置编码+字体+中文翻译文件
    QtHelper::initAll();

    //读取配置文件
    AppConfig::ConfigFile = QString("%1/%2.ini").arg(QtHelper::appPath()).arg(QtHelper::appName());
    AppConfig::readConfig();

    AppData::Intervals << "1" << "10" << "20" << "50" << "100" << "200" << "300" << "500" << "1000" << "1500" << "2000" << "3000" << "5000" << "10000";
    AppData::readSendData();
    AppData::readDeviceData();

    frmMain w;
    w.setWindowTitle("西湖机器人Telemtry");
    w.resize(1200, 960);
    QtHelper::setFormInCenter(&w);
    w.show();
    return a.exec();
}
